<?php

class library{

    public function getTrackNo($db , $referencePrefix, $referenceType, $insert_result) {
       
        if ($referenceType == 'Sequential') {
            $trackNo = $referencePrefix . '%1$04d';
           
            return sprintf($trackNo, $insert_result);
        } else {
			$dateNow = $db->query('SELECT Now() as DateTimeNow','row');
            $date = new DateTime($dateNow['DateTimeNow']);

            $trackNo = $referencePrefix . date_format($date, '-ymd-himA');
            return $trackNo;
        }
    }

}

?>